﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ModelDinhMuc.Model;
namespace TinhNguyenVatLieuSanBay
{
    public partial class Frmlogin : Form
    {
        public Frmlogin()
        {
            InitializeComponent();
        }
        DINHMUCSANBAYDB db = new DINHMUCSANBAYDB();
        private void btndangnhap_Click(object sender, EventArgs e)
        {
            IList<User> lst;
            lst = db.checklogin(txtusername.Text, txtpassword.Text).ExecuteTypedList<User>();
            if (lst != null && lst.Count > 0)
            {
                HeThong frm = new HeThong(txtusername.Text);
                frm.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Đăng nhập không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtpassword.Clear();
                txtusername.Focus();
            }
        }

        private void btnthoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
